public void FillProgrammeTree(TreeView treeView, ProgramTreeItem [] treeItemArray, string sortBy)
{
SortBy = sortBy;
//**************
//This method Sorts and then loops through an Array of ProgrammeTreeItems to load them into
//a Treview control that is passed in.
//**************
//
//Pull in the global settings
Settings guideParams = Global.Settings;
//Create a new sort object for the arrary of TreeItems
ProgramTreeItem_Sort sortArray;
//Initialize the sort object with the correct sort parameter that defines what order the items will
//be sorted in
switch (SecondarySortBy)
{
case "mrs_title":
{
switch (sortBy)
{
case "title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "originalAirDate":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByOriginalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_channel":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByChannel, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_status":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStatus, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
case "mr_original_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByOrignalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
default:
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByTitle);
break;
}
}
break;
}
case "mrs_date":
{
switch (sortBy)
{
case "title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_title":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_genre":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByGenre, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_rating":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_star":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStarRating, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_channel":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByChannel, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_status":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByStatus, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
case "mr_original_date":
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.mr_sortByOrignalAirDate, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
default:
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
}
break;
}
default:
{
sortArray = new ProgramTreeItem_Sort(ProgramTreeItem_Sort.treeSortOrder.sortByTitle, ProgramTreeItem_Sort.treeSecondarySortOrder.secondarySortByDate);
break;
}
}
//Sort the array of TreeItems using the custom sort object
Array.Sort(treeItemArray, sortArray);
//Initialize looping variables to 0
int idx1 = 0;
int idx2 = 0;
//Initialize all the display nodes for the tree
TreeNode alternateRoot = new TreeNode();
TreeNode root = new TreeNode();
TreeNode child1 = new TreeNode();
TreeNode child2 = new TreeNode();
TreeNode child3 = new TreeNode();
TreeNode child4 = new TreeNode();
TreeNode child5 = new TreeNode();
TreeNode child6 = new TreeNode();
TreeNode child7 = new TreeNode();
TreeNode child8 = new TreeNode();
TreeNode child9 = new TreeNode();
TreeNode child10 = new TreeNode();
TreeNode child11 = new TreeNode();
TreeNode child12 = new TreeNode();
//Loop through all the TreeItems in the array....building the TreeView
while (idx1 < treeItemArray.Length)
{
//Set idx2 to the previous index number....this is used to compare the current item to the
//previous item that was loaded into the tree....this tells us where to break to build a new node
idx2 = idx1 - 1;
//Set variable treeItem1 to the first array object
ProgramTreeItem treeItem1 = treeItemArray[idx1];
//Initialize the variable treeItem2
ProgramTreeItem treeItem2 = new ProgramTreeItem();
//We only want to set the variable treeItem2 to the previous item in the array if we have already
//loaded the first item in the array....so if the previous index number (idx2) is 0 or greater we
//have processed the first item in the array already
if (idx2 > -1)
{
treeItem2 = treeItemArray[idx2];
}
//If we are on the first item in the array then we need to load the info into the TreeView and move
//on to processing the next array item
if (idx1 == 0)
{
//If the sort is on anything but title we have to build the main grouper node
if (sortBy != "title" && sortBy != "mr_title")
{
if (sortBy == "status" || sortBy == "mr_status")
{
//Set the grouper node to not do anything when the text of the node is clicked on